/*
 	Software Author: Mike Moore
 	Vectrics Flashrecruit
 	Open source job board and applicant tracking system.  Built with enterprise Java.
 	GPL License applies to this source code.
 */
package org.vectrics.struts;

import java.util.Iterator;

import org.vectrics.common.html.Cell;
import org.vectrics.common.html.Row;
import org.vectrics.common.html.Table;
import org.vectrics.domain.Domain;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.system.SystemConstant;

public class SystemConstantListTag extends VectricsTagSupport {

	private static final long serialVersionUID = 3972514450675366685L;

	public SystemConstantListTag() {
		super();
	}

	protected String makeStartTag() {
		Table table = new Table();
		Domain domain = ThreadProperties.getDomain();
		Iterator systemConstants = CoreServiceLocator.getSystemService().findAllSystemConstants(domain, false);
		while (systemConstants.hasNext()) {
			SystemConstant systemConstant = (SystemConstant)systemConstants.next();
			Row row = table.addRow();
			Cell topCell = row.addCell();
			topCell.setColSpan(4);
			topCell.addText("stdFont", systemConstant.getDescription());
			topCell.setClass("formBg1");
			row = table.addRow();
			row.setDefaultCellClass("formBg2");
			Cell cell = row.addCell();
			cell.addText("stdFont", systemConstant.getCode());
			
			cell = row.addCell();
			cell.addText("stdFont", systemConstant.getType());
			
			cell = row.addCell();
			cell.addText("stdFont", "<b>Value:&nbsp;</b>" + systemConstant.getValue());
			
			cell = row.addCell();
			
/*			
			A changeLink = new A();
			changeLink.setHref("/admin/settings/change.do&code=" + systemConstant.getCode());
			changeLink.addElement(this.getPhrase("phrase.edit"));
			changeLink.setClass("stdLink");
			cell.addElement(changeLink);
			
			if (systemConstants.hasNext()) {
				Row blankRow = table.addRow();
				cell = blankRow.addCell();
				cell.setColSpan(4);
				cell.addElement("&nbsp;");
			}
		*/
		}
		
		
		
		return table.toString();
	}

}
